package springboard.auth.service;

import org.springframework.data.domain.Page;
import springboard.auth.bean.Account;
import springboard.auth.bean.Permission;
import springboard.auth.bean.Role;
import springboard.auth.bean.User;

import javax.annotation.Nullable;
import java.util.Date;
import java.util.List;
import java.util.Set;

public interface AuthService {

    User getUser(long id);
    Page<User> listUsers(@Nullable String keyword, @Nullable Date createdTime0, @Nullable Date createdTime1, int... pagination);
    List<User> findUserByPhone(String phone, Short phoneStatusVerified);
    User createUser(User user);
    User updateUser(User user);

    Permission getPermission(String key);
    List<Permission> listPermissions();

    Role getRole(String key);
    List<Role> listRoles();
    Role createRole(Role role);
    Role updateRole(Role role, String oldKey);
    int deleteRole(String key);

    Account getAccount(String username);
    Page<Account> listUserAccounts(String keyword, int[] pagination);
    List<Account> findUserAccounts(long userid);
    User findUserByUsername(String username);
    User authc(String username, String password);
    User authc(Account account, String password);
    Account createAccount(Account account);
    Account updateAccount(Account account);
    String updateUserPassword(long userId, String password);

    List<Permission> findUserPermissions(long userId);
    Set<String> findUserPermissionKeys(long userId);
    Set<String> findAllUserPermissionKeys(long userId);
    int giveUserPermissions(long userId, String... permissionKeys);
    int ungiveUserPermissions(long userId, String... permissionKeys);

    List<Role> findUserRoles(long userId);
    Set<String> findUserRoleKeys(long userId);
    int giveUserRoles(long userId, String... roleKeys);
    int ungiveUserRoles(long userId, String... roleKeys);

    List<Permission> findRolePermission(String key);
    Set<String> findRolePermissionKeys(String key);
    int giveRolePermissions(String key, String... permissionKeys);
    int ungiveRolePermissions(String key, String... permissionKeys);

}
